function loadDropdown(dropdownId, apiUrl) {
    const dropdownContent = document.getElementById(dropdownId);

    // 清空现有的内容
    dropdownContent.innerHTML = '';

    // 使用fetch API获取数据
    fetch(apiUrl)
        .then(response => {
            if (!response.ok) {
                throw new Error('Network response was not ok');
            }
            return response.json(); // 解析JSON数据
        })
        .then(data => {
            // 遍历后台数据数组
            data.forEach(item => {
                // 创建一个新的<a>元素
                const newLink = document.createElement('a');
                newLink.href = '#';
                newLink.textContent = item.label;
                newLink.onclick = function () {
                    sendLabels(item.value);
                    return false;
                };

                // 将新的<a>元素添加到.dropdown-content元素中
                dropdownContent.appendChild(newLink);
            });
        })
        .catch(error => {
            console.error('There has been a problem with your fetch operation:', error);
        });
}

// 调用函数来加载Domestic下拉菜单
loadDropdown('Domestic', '/api/domestic');

// 调用函数来加载Foreign下拉菜单
loadDropdown('Foreign', '/api/foreign');

// 调用函数来加载Startups下拉菜单
loadDropdown('Startups', '/api/startups');

// 调用函数来加载University下拉菜单
loadDropdown('Isomerism', '/api/Isomerism');

// 调用函数来加载Datasets下拉菜单
loadDropdown('Datasets', '/api/datasets');

